/* test1.c */

/****************************************************************************

Testbed for FileSwitch/FileCore experiments


****************************************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include "swis.h"


/***************************************************************************/

static void bad_swi(int x)

/* called if a _swi(...) call unexpectedly fails */

{
  _kernel_oserror *e;

  e = _kernel_last_oserror();

  printf("Unexpected SWI error %d:\n  '%s'\n", e->errnum, e->errmess);
  exit(0);
}

/***************************************************************************/

int main(int argc, char *argv[])

{
  char *buff = "HELLO\n";
  int handl1, handl2;
  int i;

 /* set up error handler for _swi calls that go wrong unexpectedly  */
  signal(SIGOSERROR, bad_swi);

 /* create an open a new file for output */
  handl1 = _swi(OS_Find, I0|I1, 0x80, "scsi::connor1.$.filesys.zy");

 /* create an open a new file for output */
  handl2 = _swi(OS_Find, I0|I1, 0x80, "scsi::connor1.$.filesys.zz");

 /* write a few bytes to the start of the first file */
  _swi(OS_GBPB, I0|I1|I2|I3, 2, handl1, (int)buff, 6);

 /* write 6 bytes at a time repeatedly to second file */
  for (i=0; i<1000; i++)
    _swi(OS_GBPB, I0|I1|I2|I3, 2, handl2, (int)buff, 6);

 /* close the second file */
  _swi(OS_Find, I0|I1, 0, handl2);

 /* and the first file */
  _swi(OS_Find, I0|I1, 0, handl1);

  return 0;
}

/***************************************************************************/
